<template>
  <VCard>
    <VCardTitle>咨询师API测试页面</VCardTitle>
    <VCardText>
      <VBtn @click="testAPI" :loading="loading">测试API</VBtn>
      <div v-if="result" class="mt-4">
        <h3>测试结果：</h3>
        <pre>{{ JSON.stringify(result, null, 2) }}</pre>
      </div>
    </VCardText>
  </VCard>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useUserStore } from '@/store/userStore';
import { getMyStudents } from '@/api/consultant';

const userStore = useUserStore();
const loading = ref(false);
const result = ref(null);

const testAPI = async () => {
  loading.value = true;
  try {
    console.log('当前用户信息:', userStore.getCurrentUser);
    console.log('用户ID:', userStore.id);
    
    const response = await getMyStudents(userStore.id || 9); // 使用咨询师ID 9作为测试
    console.log('API响应:', response);
    result.value = response.data;
  } catch (error) {
    console.error('API测试失败:', error);
    result.value = { error: error.message };
  } finally {
    loading.value = false;
  }
};
</script> 